package xml;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

import org.dom4j.Document;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

public class Dom4JXmlWriter
{
	public void writeXml(String path) throws IOException
	{
		Document doc = DomHolder.getInstance().getDom();
		FileOutputStream fos = null;
		XMLWriter writer = null;
		try
		{
			fos = new FileOutputStream(path);
			OutputFormat format = OutputFormat.createPrettyPrint();
			writer = new XMLWriter(fos, format);
			writer.write(doc);
			
			
		}
		catch (FileNotFoundException e)
		{
			throw new FileNotFoundException("XmlWriter : File Not found");
		}
		catch (UnsupportedEncodingException e)
		{
			throw new UnsupportedEncodingException();
		}
		finally
		{
//			writer.flush();	
			writer.close();
		}
		
		
	}
}
